package com.dci.service.impl.project;

import com.dci.dao.pms.project.ProjectFundManagementMapper;
import com.dci.model.project.ProjectFundManagement;
import com.dci.service.project.ProjectFundManagementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.service.impl.project
 * @Description: 项目资金管理实现类
 * @author: 张星亮
 * @date: 2019/2/25
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Service
public class ProjectFundManagementServiceImpl implements ProjectFundManagementService {

    @Resource
    private ProjectFundManagementMapper mapper;

    @Override
    public List<ProjectFundManagement> selectByBig() {
        List<ProjectFundManagement> list = mapper.selectByBig();
        if (list.size() > 0) {
            for (ProjectFundManagement projectFundManagement : list) {
                ProjectFundManagement pfm = ProjectFundManagement.builder().service_big(projectFundManagement.getService_big()).build();
                List<ProjectFundManagement> list1 = mapper.selectByAll(pfm);
                if (list1.size() > 0) {
                    int money = 0;
                    for (ProjectFundManagement pfm1 : list1) {
                        money += Integer.valueOf(pfm1.getMoney());
                    }
                    projectFundManagement.setMoneyAll(money);
                }
            }
        }
        return list;
    }

    @Override
    public List<ProjectFundManagement> selectByMiddle(ProjectFundManagement projectFundManagement) {
        List<ProjectFundManagement> list = mapper.selectByMiddle(projectFundManagement);
        if (list.size() > 0) {
            for (ProjectFundManagement projectFundManagement1 : list) {
                ProjectFundManagement pfm = ProjectFundManagement.builder().service_big(projectFundManagement1.getService_big()).service_middle(projectFundManagement1.getService_middle()).build();
                List<ProjectFundManagement> list1 = mapper.selectByAll(pfm);
                if (list1.size() > 0) {
                    int money = 0;
                    for (ProjectFundManagement pfm1 : list1) {
                        money += Integer.valueOf(pfm1.getMoney());
                    }
                    projectFundManagement1.setMoneyAll(money);
                }
            }
        }
        return list;
    }

    @Override
    public List<ProjectFundManagement> selectBySmall(ProjectFundManagement projectFundManagement) {
        List<ProjectFundManagement> list = mapper.selectBySmall(projectFundManagement);
        if (list.size() > 0) {
            for (ProjectFundManagement projectFundManagement1 : list) {
                ProjectFundManagement pfm = ProjectFundManagement.builder().service_big(projectFundManagement1.getService_big()).service_middle(projectFundManagement1.getService_middle()).service_small(projectFundManagement1.getService_small()).build();
                List<ProjectFundManagement> list1 = mapper.selectByAll(pfm);
                if (list1.size() > 0) {
                    int money = 0;
                    for (ProjectFundManagement pfm1 : list1) {
                        money += Integer.valueOf(pfm1.getMoney());
                    }
                    projectFundManagement1.setMoneyAll(money);
                }
            }
        }
        return list;
    }
}
